//
//  ST_DTFemaleInviteChatCell.swift
//  btvideo
//
//  Created by Jason on 2021/12/13.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//

import UIKit

class ST_DTFemaleInviteChatCell: ST_DTChatCell {
    
    override func commonInit() {
        super.commonInit()
    }
    
    static let height = (40+15).cgFloat
    
    fileprivate lazy var box_view:UIView = {
        let control = UIView()
        control.cornerRadius = 20
        
        let tap = UITapGestureRecognizer.init(target: self, action: #selector(cell_click))
        
        control.addGestureRecognizer(tap)
        
        return control
    }()
    
    /// 回拨通话 1 语音 2 视频
    var recall_female_chat_invited:((Int)->())?
    
    @objc fileprivate func cell_click(){
        
        
        guard let chatType = message.femaleInviteChatType else{
            return
        }
//
        recall_female_chat_invited?(chatType)
    }
    
    fileprivate lazy var icon_image_view:UIImageView = {
        let control = UIImageView()
        return control
    }()
    
    fileprivate lazy var invite_title_label:UILabel = {
        let l = UILabel()
        return l
    }()
    
    
}




//MARK: - Left


class ST_DTFemaleInviteChatLeftCell: ST_DTFemaleInviteChatCell {
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func commonInit() {
        super.commonInit()
        
        icon.snp.makeConstraints { (make) in
            make.width.height.equalTo(DTChatUserImageWidth)
            make.left.top.equalToSuperview().offset(15)
        }
        
        contentView.addSubview(box_view)
        box_view.snp.makeConstraints { (make) in
            make.width.equalTo(246)
            make.height.equalTo(40)
            make.left.equalTo(icon.snp.right).offset(4)
            make.top.equalTo(icon)
        }
        
        
        box_view.addSubview(icon_image_view)
        icon_image_view.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(17)
            make.height.width.equalTo(20)
        }
        
        box_view.addSubview(invite_title_label)
        invite_title_label.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(47)
        }
        
        
        
        box_view.addSubview(callback_title_label)
        callback_title_label.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-17)
            make.height.equalTo(26)
            make.width.equalTo(46)
        }
        
        
        icon_image_view.image = ST_ImageUtils.imageName("chat_cell_female_invite_left_icon")
        
        box_view.backgroundColor = UIColor(hex: 0xF2F4F7)
        
        invite_title_label.textColor = UIColor(hex: 0x8290A5)
        invite_title_label.font = .systemFont(ofSize: 14, weight: .regular)
    }
    
    
    fileprivate lazy var callback_title_label:UILabel = {
        let l = UILabel()
        l.backgroundColor = UIColor(hex: 0x8290A5)
        l.text = "回拨"
        l.font = .systemFont(ofSize: 14, weight: .regular)
        l.textColor = .white
        l.cornerRadius = 13
        l.textAlignment = .center
        return l
    }()
    
    
    override var message: ST_DTChatMessage!{
        didSet{
            
            if uuid == message.uuid{
                return
            }
            
            
            self.uuid = message.uuid
            
            icon.sd_setImage(with: message.portraitUri.compress_image().url,for: UIControl.State.normal, completed: nil)
            
            if message.femaleInviteChatType == 1{
                invite_title_label.text = "对方邀请你语音通话"
            }else{
                invite_title_label.text = "对方邀请你视频通话"
            }
            
        }
    }
}


//MARK: - Right
class ST_DTFemaleInviteChatRightCell: ST_DTFemaleInviteChatCell {
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func commonInit() {
        super.commonInit()
        
        contentView.addSubview(box_view)
        box_view.snp.makeConstraints { (make) in
            make.width.equalTo(204)
            make.height.equalTo(40)
            make.right.equalToSuperview().offset(-15)
            make.top.equalToSuperview().offset(15)
        }
        
        box_view.addSubview(icon_image_view)
        icon_image_view.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(17)
            make.width.height.equalTo(20)
        }
        
        box_view.addSubview(invite_title_label)
        invite_title_label.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(47)
        }
        
        icon_image_view.image = ST_ImageUtils.imageName("chat_cell_female_invite_right_icon")
        box_view.backgroundColor = UIColor(hex: 0xFEC207)
        
        invite_title_label.textColor = .white
        invite_title_label.font = .systemFont(ofSize: 14, weight: .regular)
        
    }
    
    
    override var message: ST_DTChatMessage!{
        didSet{
            
            if uuid == message.uuid{
                return
            }
            
            
            self.uuid = message.uuid
            
            icon.sd_setImage(with: message.portraitUri.compress_image().url,for: UIControl.State.normal, completed: nil)
            
            if message.femaleInviteChatType == 1{
                invite_title_label.text = "你发起了语音通话邀约"
            }else{
                invite_title_label.text = "你发起了视频通话邀约"
            }
            
        }
    }
    
}
